package com.cc.service.Impl;

import com.cc.entity.Employee;
import com.cc.mapper.EmployeeMapper;
import com.cc.service.EmployeeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
    public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    EmployeeMapper employeeMapper;


    @Override
    public List<Employee> getAllEmployee() {
        return employeeMapper.getAllEmployee();
    }

    @Override
    public PageInfo<Employee> getEmployeeByPage(Integer pageNum) {
        PageHelper.startPage(pageNum,5);
        List<Employee> employeeList = employeeMapper.getAllEmployee();
        PageInfo<Employee> pageInfo = new PageInfo<>(employeeList);
        return pageInfo;
    }


    @Override
    public int addEmployee(Employee employee) {
        return employeeMapper.addEmployee(employee);
    }
}
